//引入异步模块
import myAxios from '@/utils/request'

enum Api {
    //根据spuId获取sku数据
    getSkuListApi = '/admin/product/findBySpuId',
    //添加skuInfo
    saveSkuInfoApi = '/admin/product/saveSkuInfo',
    //获取所有的sku信息接口
    getAllSkuListApi = '/admin/product/list',
    //sku上架
    skuOnSaleApi = '/admin/product/onSale',
    //sku下架
    skuCancleApi = '/admin/product/cancelSale',
    //删除sku
    deleteSkuApi = '/admin/product/deleteSku',
    //获取一条sku信息
    getOneSkuInfoApi = '/admin/product/getSkuById'
}


//定义接口数据
export const reqSaveSkuInfo = (skuInfo) => {
    return myAxios.post<any, any>(`${Api.saveSkuInfoApi}`, skuInfo)
}

//根据spuID获取sku数据
export const reqGetSkuListData = (spuId) => {
    return myAxios.get<any, any>(`${Api.getSkuListApi}/${spuId}`)
}

//获取所有的sku信息接口
export const reqGetAllSkuList = (page: number, limit: number) => {
    return myAxios.get<any, any>(`${Api.getAllSkuListApi}/${page}/${limit}`)
}

//上架
export const reqSkuOnSale = (skuId: number) => {
    return myAxios.get<any, any>(Api.skuOnSaleApi + `/${skuId}`)
}

//下架
export const reqSkuCancleSale = (skuId: number) => {
    return myAxios.get<any, any>(Api.skuCancleApi + `/${skuId}`)
}

//删除sku
export const reqDeleteSku = (skuId: number) => {
    return myAxios.delete<any, null>(`${Api.deleteSkuApi}/${skuId}`)
}

//获取一条sku信息
export const reqGetOneSkuInfo = (skuId: number) => {
    return myAxios.get<any, any>(`${Api.getOneSkuInfoApi}/${skuId}`)
}